<template>
	<view class="container">
		<view class="order-type-container">
			<view class="order-type-item-container" v-if="servePlayerStatus && checkWetchatEnableYueWan('') && servePlayType == '2'">
				<view class="order-type-item" @click="navigateTo(7)">
					<image :src="menuServerOrderIcon" class="order-icon"></image>
					<view class="order-text">教练订单</view>
				</view>
			</view>
			<view class="order-type-item-container" v-if="servePlayerStatus && checkWetchatEnableYueWan('') && servePlayType == '1'">
				<view class="order-type-item" @click="navigateTo(0)">
					<image :src="menuServerOrderIcon" class="order-icon"></image>
					<view class="order-text">教练订单</view>
				</view>
			</view>
			<view class="order-type-item-container" v-if="checkWetchatEnableYueWan('')">
				<view class="order-type-item" @click="navigateTo(6)">
					<image :src="menuOnlineplayOrderIcon" class="order-icon"></image>
					<view class="order-text">线上订单</view>
				</view>
			</view>
			<view class="order-type-item-container" v-if="checkWetchatEnableYueWan('')">
				<view class="order-type-item" @click="navigateTo(1)">
					<image :src="menuPlayOrderIcon" class="order-icon"></image>
					<view class="order-text">线下订单</view>
				</view>
			</view>
			<view v-for="(item, index) in orderTypeList" :key="index" class="order-type-item-container" @click="navigateTo(item.flag)">
				<view class="order-type-item">
					<image :src="item.icon" class="order-icon"></image>
					<view class="order-text">{{ item.text }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { isLogin, toLogin, showShareMenu } from '@/config/common.js';
import { getAppServePlayerApplyStatus } from '@/constant/schedule.js';
import { checkWetchatEnableYueWan } from '@/config/utils.js';
import menuMallOrderIcon from '@/static/images/menu-mall-order-icon.png';
import menuPlayOrderIcon from '@/static/images/menu-play-order-icon.png';
import menuRechangeOrderIcon from '@/static/images/menu-rechange-order-icon.png';
import menuRoomOrderIcon from '@/static/images/menu-room-order-icon.png';
import menuVipOrderIcon from '@/static/images/menu-vip-order-icon.png';
import menuServerOrderIcon from '@/static/images/menu-sever-order-icon.png';
import menuOnlineplayOrderIcon from '@/static/images/menu-onlineplay-order-icon.png';
export default {
	components: {},
	data() {
		return {
			sellList: ['', '', ''],
			servePlayerStatus: false,
			servePlayType: 0,
			customer_id: uni.getStorageSync('customerId'),
			checkWetchatEnableYueWan: checkWetchatEnableYueWan,
			menuServerOrderIcon: menuServerOrderIcon,
			menuRechangeOrderIcon: menuRechangeOrderIcon,
			menuOnlineplayOrderIcon: menuOnlineplayOrderIcon,
			menuPlayOrderIcon: menuPlayOrderIcon,
			orderTypeList: [
				{
					flag: 2,
					icon: menuVipOrderIcon,
					text: 'VIP订单'
				},
				{
					flag: 3,
					icon: menuRoomOrderIcon,
					text: '客房订单'
				},
				{
					flag: 4,
					icon: menuMallOrderIcon,
					text: '商城订单'
				},
				{
					flag: 5,
					icon: menuRechangeOrderIcon,
					text: '充值订单'
				}
			]
		};
	},
	onLoad() {
		if (isLogin()) {
			this.getApplyStatus();
		} else {
			toLogin();
		}
		showShareMenu();
	},
	methods: {
		async getApplyStatus() {
			let result = await getAppServePlayerApplyStatus({ servePlayerId: this.customer_id });
			if (result && result.PlayerApplyStatus == 20) {
				this.servePlayerStatus = true;
				this.servePlayType = result.ServePlayType;
			}
		},
		navigateTo: function(val) {
			let url = '';
			switch (val) {
				case 0:
					url = '/packagePages/playercenter/setting/order/list';
					break;
				case 1:
					url = '/packagePages/order/playerorder/list';
					break;
				case 2:
					url = '/packagePages/order/viporder/list';
					break;
				case 3:
					url = '/packagePages/order/roomorder/list';
					break;
				case 4:
					url = '/packagePages/order/mallorder/list';
					break;
				case 5:
					url = '/packagePages/order/rechargeorder/list';
					break;
				case 6:
					url = '/packagePages/order/onlineplayerorder/list';
					break;
				case 7:
					url = '/packagePages/onlinePlayCenter/setting/order/list';
					break;
			}
			uni.navigateTo({
				url: url
			});
		}
	}
};
</script>
<style>
@import url('../../css/common.css');
</style>
<style scoped lang="scss">
.container {
	overflow-y: auto;
}

.order-type-container {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	padding-top: 40rpx;
}

.order-type-item-container {
	width: 33%;
	text-align: center;
	margin-bottom: 60rpx;

	.order-type-item {
		.order-icon {
			width: 72rpx;
			height: 72rpx;
			margin-bottom: 10rpx;
		}

		.order-text {
			color: $main-text-color-gray-33;
			font-size: $main-text-size-28;
			font-family: 'SourceHanSansCN-Regular';
		}
	}
}

.order-type-container::after {
	content: '';
	width: 33%;
}
</style>
